package cn.wolfcode.cms.service.impl;

import cn.wolfcode.cms.domain.DictionaryItems;
import cn.wolfcode.cms.mapper.DictionaryItemsMapper;
import cn.wolfcode.cms.query.QueryObject;
import cn.wolfcode.cms.service.IDictionaryItemsService;
import cn.wolfcode.cms.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DictionaryItemsServiceImpl implements IDictionaryItemsService {

    @Autowired
    private DictionaryItemsMapper dictionaryItemsMapper;

    public void save(DictionaryItems entity) {
        dictionaryItemsMapper.insert(entity);

    }

    public void update(DictionaryItems entity) {
        dictionaryItemsMapper.updateByPrimaryKey(entity);
    }

    public void delete(Long id) {
        dictionaryItemsMapper.deleteByPrimaryKey(id);
    }

    public DictionaryItems get(Long id) {
        return dictionaryItemsMapper.selectByPrimaryKey(id);
    }

    public List<DictionaryItems> list() {
        return dictionaryItemsMapper.selectAll();
    }

    public Object query(QueryObject qo) {
        //查总数
        int total = dictionaryItemsMapper.queryForCount(qo);
        if (total == 0) {
            return new PageResult();
        }
        //查数据
        List<DictionaryItems> rows = dictionaryItemsMapper.queryForList(qo);
        return new PageResult(total, rows);
    }

    @Override
    public Object getItemByDataDictionarySn(String sn) {
        return dictionaryItemsMapper.getItemByDataDictionarySn(sn);
    }

    @Override
    public Object selectAllSn() {
        return dictionaryItemsMapper.selectAllSn();
    }

 

}
